import defineReactiveData from './defineReactiveData.js'
import { arrMenthods } from './array'
import observeArr from './observeArr.js';

function Observer(data){
    // console.log(data);
    if(Array.isArray(data)){
        data.__proto__ = arrMenthods;
        // console.log(arrMenthods);
        observeArr(data);
    }else{
        this.walk(data);
    }
}

Observer.prototype.walk = function (data){
    // console.log(data)
    let keys = Object.keys(data)
    for (let i = 0;i<keys.length;i++){
        var key = keys[i];
        var value = data[key];
        defineReactiveData(data,key,value);
    }
}
export default Observer;